package org.tang.data;
import java.util.ArrayList;
import java.util.List;

import org.tang.data.common.Constant;
import org.tang.data.common.Utils;
import org.tang.data.entity.DayKEntity;

public class GenateK {

	public static void main(String[] args) {
		try {
			List<String> dateList = Utils.betweenDate("2012-12-04",
					"2013-02-02");
			List<String> stocks = Utils.getStocks();
			for (int i = 0; i < stocks.size(); i++) {
				String stockNumber = stocks.get(i);
				List<DayKEntity> DayKEntityList = new ArrayList<DayKEntity>();
				for (int j = 0; j < dateList.size(); j++) {
					String dateString = dateList.get(j);
					DayKEntity tmp = formStock(stockNumber, dateString);
					if (tmp != null)
						DayKEntityList.add(tmp);
				}
				String fileName = Constant.dirPre + Constant.dayKDir + stockNumber + ".txt";
				DayKEntity.saveListToFile(fileName, DayKEntityList);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static DayKEntity formStock(String stockNumber, String dateString)
			throws Exception {
		String fileName = Constant.dirPre + dateString + "\\" + stockNumber
				+ ".txt";
		return DayKEntity.instance(fileName, dateString);
	}

}


